package utils.test;

import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import cx.ath.choisnet.swing.LimitedIntegerJTextField;
import cx.ath.choisnet.swing.LimitedJTextField;

//VS4E -- DO NOT REMOVE THIS LINE!
public class TstLimitedXTextField extends JFrame {

    private static final long   serialVersionUID        = 1L;
    /** @serial */
    private JButton jButton0;
    /** @serial */
    private LimitedJTextField jTextField0;
    /** @serial */
    private LimitedIntegerJTextField jTextField1;
    private static final String PREFERRED_LOOK_AND_FEEL = "javax.swing.plaf.metal.MetalLookAndFeel";
    public TstLimitedXTextField()
    {
        initComponents();
    }

    private void initComponents() {
        setLayout(new FlowLayout());
        add(getJButton0());
        add(getJTextField1());
        add(getJTextField0());
        setSize(320, 240);
    }

    private LimitedIntegerJTextField getJTextField1() {
        if (jTextField1 == null) {
            jTextField1 = new LimitedIntegerJTextField();
            jTextField1.setMaxValue(255);
            jTextField1.setColumns( 3 );
        }
        return jTextField1;
    }

    private LimitedJTextField getJTextField0() {
        if (jTextField0 == null) {
            jTextField0 = new LimitedJTextField();
            jTextField0.setMaxLength(3);
            jTextField0.setColumns(3);
            jTextField0.setText( "str" );
        }
        return jTextField0;
    }

    private JButton getJButton0() {
        if (jButton0 == null) {
            jButton0 = new JButton();
            jButton0.setText("jButton0");
        }
        return jButton0;
    }

    @SuppressWarnings("unused")
    private static void installLnF()
    {
        try {
            String lnfClassname = PREFERRED_LOOK_AND_FEEL;
            if( lnfClassname == null )
                lnfClassname = UIManager.getCrossPlatformLookAndFeelClassName();
            UIManager.setLookAndFeel( lnfClassname );
        }
        catch( Exception e ) {
            System.err.println( "Cannot install " + PREFERRED_LOOK_AND_FEEL
                    + " on this platform:" + e.getMessage() );
        }
    }

    /**
     * Main entry of the class.
     * Note: This class is only created so that you can easily preview the result at runtime.
     * It is not expected to be managed by the designer.
     * You can modify it as you like.
     * @param args
     */
    public static void main( String[] args )
    {
        installLnF();
        SwingUtilities.invokeLater( new Runnable() {
            @Override
            public void run()
            {
                TstLimitedXTextField frame = new TstLimitedXTextField();
                frame.setDefaultCloseOperation( TstLimitedXTextField.EXIT_ON_CLOSE );
                frame.setTitle( "TstLimitedXTextField" );
                frame.getContentPane().setPreferredSize( frame.getSize() );
                frame.pack();
                frame.setLocationRelativeTo( null );
                frame.setVisible( true );
            }
        } );
    }

}
